/*
 * Licensed under the License, Version 1.0 (the "License");
 * You may obtain a copy of the License at
 *   http://www.heavenick.com/license/License 
 * Copyright information Heavenick to all.
 * Unless the applicable legal requirements or written 
 * consent, can use or around the code, and no warranties 
 * of any kind and state responsibility.
 */
package com.heavenick.core.config;

import java.io.IOException;
import java.io.Reader;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

/**
 *
 *@author Heavenick
 *@version 1.0
 *@date 2012-8-18 下午4:31:20
 */
public class BootMybatis {

	public SqlSessionFactory init(){
		try {
			Reader reader = Resources.getResourceAsReader("sqlmapconfig.xml");
			
			SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(reader);
			new SqlSessionFactoryBuilder().build(reader, "sqlMap");
			return sessionFactory;
		} catch (IOException e) {
			e.printStackTrace();
			return null;
		}
	}
	
	public static void main(String...strings){
		BootMybatis bm = new BootMybatis();
		SqlSessionFactory ssf = bm.init();
		
		SqlSession session = ssf.openSession();
	}
}
